import http from "./index.js"
/* 获取文章列表 */
const getarticlelist = (data) => {
    return new Promise((resolve, reject) => {
        http.post("/api/article/getarticle", data).then(res => {
            resolve(res)
        })
    })
}
/* 获取文章 */
const getarticle = (id) => {
    return new Promise((resolve, reject) => {
        http.get("/api/article/getarticlebyid", {
            params: {
                article_id: id
            }
        }).then(res => {
            resolve(res)
        })
    })
}
/* 根据当前文章id获取上下文章 */
const getPreAndnext = (id) => {
    return new Promise((resolve, reject) => {
        http.get("/api/article/getPreAndnext", {
            params: {
                article_id: id
            }
        }).then(res => {
            resolve(res)
        })
    })
}
/* 添加浏览量 */
const addarticleview = (id) => {
    return new Promise((resolve, reject) => {
        http.get("/api/article/addarticleview", {
            params: {
                article_id: id
            }
        }).then(res => {
            resolve(res)
        })
    })
}
/* 获取推荐文章 */
const getrecommentdarticle = (id) => {
    return new Promise((resolve, reject) => {
        http.get("/api/article/getrecommentdarticle").then(res => {
            resolve(res)
        })
    })
}
/* 获取文章数量 */
const getarticlenum = () => {
    return new Promise((resolve, reject) => {
        http.get("/api/article/getarticlenum").then(res => {
            resolve(res)
        })
    })
}
/* 获取标签 */
const getlables = () => {
    return new Promise((resolve, reject) => {
        http.get("/api/lable/getalllables").then(res => {
            resolve(res)
        })
    })
}
/* 选取标签 */
const selectlable = (data) => {
    return new Promise((resolve, reject) => {
        http.post("/api/lable/selectlable", data).then(res => {
            resolve(res)
        })
    })
}
/* 文章和位置 */
const getarticlebypos = () => {
    return new Promise((resolve, reject) => {
        http.get("/api/article/getarticlebypos").then(res => {
            resolve(res)
        })
    })
}
/* 添加赞 */
const addlike = (data) => {
    return new Promise((resolve, reject) => {
        http.post("/api/article/addlike", data).then(res => {
            resolve(res)
        })
    })
}
/* 添加评论 */
const addcomment = (data) => {
    return new Promise((resolve, reject) => {
        http.post("/api/comment/addcomment", data).then(res => {
            resolve(res)
        })
    })
}
/* 获取评论 */
const getcomment = (data) => {
    return new Promise((resolve, reject) => {
        http.get("/api/comment/getcomment", {
            params: data
        }).then(res => {
            resolve(res)
        })
    })
}
/* 回去评论的数量 */
const getcommentunm = (data) => {
    return new Promise((resolve, reject) => {
        http.get("/api/comment/getcommentunm", {
            params: data
        }).then(res => {
            resolve(res)
        })
    })
}
/* 回复评论 */
const replycomments = (data) => {
    return new Promise((resolve, reject) => {
        http.post("/api/comment/replycomments", data).then(res => {
            resolve(res)
        })
    })
}
/* 说说点赞 */
const addstrs = (data) => {
    return new Promise((resolve, reject) => {
        http.post("/api/comment/addstrs",data).then(res => {
            resolve(res)
        })
    })
}
/* 获取留言评论 */
const getliuyan = (data) => {
    return new Promise((resolve, reject) => {
        http.get("/api/comment/getliuyan",{
            params:data
        }).then(res => {
            resolve(res)
        })
    })
}
const getliuyanunm = ()=>{
    return new Promise((resolve, reject) => {
        http.get("/api/comment/getliuyanunm").then(res =>{
            resolve(res)
        })
    })
}
const getdanmu = () => {
    return new Promise((resolve, reject) => {
        http.get("/api/comment/getdanmu").then(res =>{
            resolve(res)
        })
    })
}
const adddanmu = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/comment/adddanmu",data).then(res =>{
            resolve(res)
        })
    })
}
const serchinfo = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/article/search", data).then(res => {
            resolve(res)
        })
    })
}
export {
    getarticlebypos,
    getarticlelist,
    getarticle,
    getPreAndnext,
    addarticleview,
    getrecommentdarticle,
    getarticlenum,
    getlables,
    selectlable,
    addlike,
    addcomment,
    getcomment,
    getcommentunm,
    replycomments,
    addstrs,
    getliuyan,
    getliuyanunm,
    adddanmu,
    getdanmu,
    serchinfo
}